Fix the dependency graph with root pkg cycles
authorAlex Crichton <alex@alexcrichton.com>
Wed, 24 Sep 2014 05:12:01 +0000 (22:12 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 3 Oct 2014 01:38:15 +0000 (18:38 -0700)
If the root package ended up depending on itself through some development
dependency (technically not a cycle), then the resolve phase would currently
overwrite some previous result, destroying the progress. By registering the root
package as seen early on this prevents the overwriting from happening and
instead appending happens.

src/cargo/core/resolver.rs

index d2af447b6e7828782d5c33da5fb03f7310330663..278fde481cb4d428f6ce0703a5387cdf2e40a41e 100644 (file)
@@ -306,6 +306,9 @@ pub fn resolve<R: Registry>(summary: &Summary, method: ResolveMethod,
     let _p = profile::start(format!("resolving: {}", summary));
 
     let mut context = Context::new(registry, summary.get_package_id().clone());
+    context.seen.insert((summary.get_name().to_string(),
+                         summary.get_source_id().clone()),
+                        summary.get_version().clone());
     try!(resolve_deps(summary, method, &mut context));
     log!(5, "  result={}", context.resolve);
     Ok(context.resolve)